﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using VOL.Core.Utilities;
using VOL.Domain.IServices.SchedulingManagement;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers.SchedulingManagement
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ShiftplanningController : ControllerBase
    {
        private readonly IShiftplanningService _shiftplanningService;

        public ShiftplanningController(IShiftplanningService shiftplanningService)
        {
            _shiftplanningService = shiftplanningService;
        }

        /// <summary>
        /// 批量添加排班计划
        /// </summary>
        /// <param name="shiftplannings">排班计划列表</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> BatchAddShiftplannings([FromBody] List<Shiftplanning> shiftplannings)
        {
            return await _shiftplanningService.BatchAddShiftplannings(shiftplannings);
        }

        /// <summary>
        /// 批量删除排班计划
        /// </summary>
        /// <param name="ids">要删除的ID数组</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<WebResponseContent> BatchDeleteShiftplannings([FromQuery] int[] ids)
        {
            return await _shiftplanningService.BatchDeleteShiftplannings(ids);
        }

        /// <summary>
        /// 更新排班计划
        /// </summary>
        /// <param name="shiftplanning">排班计划实体</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> UpdateShiftplanning([FromBody] Shiftplanning shiftplanning)
        {
            return await _shiftplanningService.UpdateShiftplanning(shiftplanning);
        }

        /// <summary>
        /// 获取排班计划列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<WebResponseContent> GetShiftplanningList()
        {
            return await _shiftplanningService.GetShiftplanningList();
        }
    }
}
